<template>
  <div class="wrap">
    <div class="box">
      <input type="text" v-model="signature" placeholder="请输入签名" />
      <p class="btn" @click="save">保存</p>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.wrap {
  height: 100vh;
  background: #fafafa;
  overflow: hidden;
}
.box {
  background: #fff;
  width: 8.8rem;
  padding: 0.4rem;
  margin: 15px auto;
  border-radius: 0.266667rem;
}
input {
  border: none;
  border-bottom: 1px solid #e5e5e5;
  width: 8.293333rem;
  margin: 1.066667rem auto;
  outline: none;
  height: 0.8rem;
}
.btn {
  width: 8.16rem;
  height: 1.066667rem;
  margin: 0 auto 0;
  background: #719bef;
  color: #fff;
  font-size: 0.48rem;
  text-align: center;
  line-height: 1.066667rem;
  border-radius: 0.266667rem;
}
</style>
<script>
import { updateUserInfo } from "@/utils/interface";
import { Dialog } from "vant";

export default {
  data() {
    return {
      signature: ""
    };
  },
  methods: {
    save() {
      if (!this.signature) {
        Dialog.alert({
          message: "请输入签名"
        });
        return false;
      }
      updateUserInfo({ signature: this.signature }).then(res => {
        if (res.data.code == 200) {
          Dialog.alert({
            message: "修改成功"
          }).then(res => {
            this.$router.go(-1);
          });
        }
      });
    }
  },
  created(){
    document.title="修改签名"
  }
};
</script>